package number

func Clamp(number N, lower N, upper N) N {
	if lower > upper {
		lower, upper = upper, lower
	}
	if number <= lower {
		return lower
	}
	if number >= upper {
		return upper
	}
	return number
}
